home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume29 / zsh2.2 / part02 < prev    next >
Encoding:
Text File  |  1992-05-13  |  49.1 KB  |  2,198 lines

  1. Newsgroups: comp.sources.misc
  2. From: pfalstad@phoenix.Princeton.EDU (Paul Falstad)
  3. Subject:  v29i098:  zsh2.2 - The Z shell, Part02/17
  4. Message-ID: <1992May13.155328.7924@sparky.imd.sterling.com>
  5. X-Md4-Signature: 2f21b032838f030851ae938e2335ae85
  6. Date: Wed, 13 May 1992 15:53:28 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: pfalstad@phoenix.Princeton.EDU (Paul Falstad)
  10. Posting-number: Volume 29, Issue 98
  11. Archive-name: zsh2.2/part02
  12. Environment: BSD
  13. Supersedes: zsh2.1: Volume 24, Issue 1-19
  14.  
  15. #!/bin/sh
  16. # this is aa.02 (part 2 of zsh2.2)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file zsh2.2/doc/intro.txt continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 2; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping zsh2.2/doc/intro.txt'
  34. else
  35. echo 'x - continuing file zsh2.2/doc/intro.txt'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'zsh2.2/doc/intro.txt' &&
  37. Xother hand, is replaced with the output itself.) print -l is
  38. Xlike  echo,  excepts  that  it  prints its arguments one per
  39. Xline, the way fgrep expects them:
  40. X
  41. X% print -l foo bar
  42. Xfoo
  43. Xbar
  44. X
  45. X
  46. XWe could also have written:
  47. X
  48. X% who | fgrep -f =(echo 'root
  49. X> lemke
  50. X> shgchan
  51. X> subbarao')
  52. X
  53. X
  54. XUsing process substitution, you can edit  the  output  of  a
  55. Xcommand:
  56. X
  57. X% ed =(who | fgrep -f ~/.friends)
  58. X355
  59. Xg/lemke/d
  60. Xw /tmp/filbar
  61. X226
  62. Xq
  63. X% cat /tmp/filbar
  64. Xroot     console May 19 10:41
  65. Xshgchan  ttys1   May 23 16:52   (gaudi.Princeton.)
  66. Xsubbarao ttyt7   May 23 15:02   (mad55sx15.Prince)
  67. Xsubbarao ttyu6   May 23 15:04   (mad55sx15.Prince)
  68. Xshgchan  ttyvb   May 23 16:51   (gaudi.Princeton.)
  69. X
  70. X
  71. Xor easily read archived mail:
  72. X
  73. X
  74. X
  75. X
  76. X
  77. X
  78. X
  79. X
  80. X
  81. X
  82. X
  83. X
  84. X
  85. X
  86. X
  87. X
  88. X                           - 16 -
  89. X
  90. X% mail -f =(zcat ~/mail/oldzshmail.Z)
  91. X"/tmp/zsha06024": 84 messages, 0 new, 43 unread
  92. X>  1  U  TO: pfalstad, zsh (10)
  93. X   2  U  nytim!tim@uunet.uu.net, Re: Zsh on Sparc1 /SunOS 4.0.3
  94. X   3  U  JAM%TPN@utrcgw.utc.com, zsh fix (15)
  95. X   4  U  djm@eng.umd.edu, way to find out if running zsh? (25)
  96. X   5  U  djm@eng.umd.edu, Re: way to find out if running zsh? (17)
  97. X   6   r djm@eng.umd.edu, Meta . (18)
  98. X   7  U  jack@cs.glasgow.ac.uk, Re: problem building zsh (147)
  99. X   8  U  nytim!tim@uunet.uu.net, Re: Zsh on Sparc1 /SunOS 4.0.3
  100. X   9     ursa!jmd, Another fix... (61)
  101. X  10  U  pplacewa@bbn.com, Re: v18i084: Zsh 2.00 - A small complaint (36)
  102. X  11  U  lubkin@cs.rochester.edu, POSIX job control (34)
  103. X  12  U  yale!bronson!tan@uunet.UU.NET
  104. X  13  U  brett@rpi.edu, zsh (36)
  105. X  14  S  subbarao, zsh sucks!!!! (286)
  106. X  15  U  snibru!d241s008!d241s013!ala@relay.EU.net, zsh (165)
  107. X  16  U  nytim!tim@uunet.UU.NET, Re: Zsh on Sparc1 /SunOS 4.0.3
  108. X  17  U  subbarao, zsh is a junk shell (43)
  109. X  18  U  amaranth@vela.acs.oakland.edu, zsh (33)
  110. X43u/84 1: x
  111. X% ls -l /tmp/zsha06024
  112. X/tmp/zsha06024 not found
  113. X
  114. X
  115. XNote that the shell creates a temporary file, and deletes it
  116. Xwhen the command is finished.
  117. X
  118. X% diff =(ls) =(ls -F)
  119. X3c3
  120. X< fortune
  121. X---
  122. X> fortune*
  123. X10c10
  124. X< strfile
  125. X---
  126. X> strfile*
  127. X
  128. X
  129. XIf you read zsh's man page, you may notice  that  <(...)  is
  130. Xanother  form  of  process  substitution which is similar to
  131. X=(...).  There is an important difference between  the  two.
  132. XIn  the  <(...)  case, the shell creates a named pipe (FIFO)
  133. Xinstead of a file.  This is better, since it does  not  fill
  134. Xup  the  file system; but it does not work in all cases.  In
  135. Xfact, if we had replaced =(...) with <(...) in the  examples
  136. Xabove,  all  of  them  would have stopped working except for
  137. Xfgrep -f <(...).  You can not edit a pipe, or open it  as  a
  138. Xmail  folder;  fgrep, however, has no problem with reading a
  139. Xlist of words from a pipe.  You may wonder why  diff  <(foo)
  140. Xbar  doesn't  work,  since  foo  | diff - bar works; this is
  141. Xbecause diff creates a temporary file if it notices that one
  142. Xof its arguments is -, and then copies its standard input to
  143. Xthe temporary file.
  144. X
  145. XAliasing
  146. X
  147. XOften-used commands can be abbreviated with an alias:
  148. X
  149. X
  150. X
  151. X
  152. X
  153. X
  154. X                           - 17 -
  155. X
  156. X% alias uc=uncompress
  157. X% ls
  158. Xhanoi.Z
  159. X% uc hanoi
  160. X% ls
  161. Xhanoi
  162. X
  163. X
  164. Xor commands with certain desired options:
  165. X
  166. X% alias fm='finger -m'
  167. X% fm root
  168. XLogin name: root                        In real life: Operator
  169. XDirectory: /                            Shell: /bin/csh
  170. XOn since May 19 10:41:15 on console     3 days 5 hours Idle Time
  171. XNo unread mail
  172. XNo Plan.
  173. X
  174. X% alias lock='lock -p -60000'
  175. X% lock
  176. Xlock: /dev/ttyr4 on phoenix. timeout in 60000 minutes
  177. Xtime now is Fri May 24 04:23:18 EDT 1991
  178. XKey:
  179. X
  180. X% alias l='ls -AF'
  181. X% l /
  182. X.bash_history              kadb*
  183. X.bashrc                    lib@
  184. X.cshrc                     licensed/
  185. X.exrc                      lost+found/
  186. X.login                     macsyma
  187. X
  188. X
  189. XAliases can also be used to replace old commands:
  190. X
  191. X% alias grep=egrep ps=sps make=gmake
  192. X% alias whoami='echo root'
  193. X% whoami
  194. Xroot
  195. X
  196. X
  197. Xor to define new ones:
  198. X
  199. X
  200. X
  201. X
  202. X
  203. X
  204. X
  205. X
  206. X
  207. X
  208. X
  209. X
  210. X
  211. X
  212. X
  213. X
  214. X
  215. X
  216. X
  217. X
  218. X
  219. X
  220. X                           - 18 -
  221. X
  222. X% cd /
  223. X% alias sz='ls -l | sort -n +3 | tail -10'
  224. X% sz
  225. Xdrwxr-sr-x  7 bin          3072 May 23 11:59 etc
  226. Xdrwxrwxrwx 26 root         5120 May 24 04:20 tmp
  227. Xdrwxr-xr-x  2 root         8192 Dec 26 19:34 lost+found
  228. Xdrwxr-sr-x  2 bin         14848 May 23 18:48 dev
  229. X-r--r--r--  1 root       140520 Dec 26 20:08 boot
  230. X-rwxr-xr-x  1 root       311172 Dec 26 20:08 kadb
  231. X-rwxr-xr-x  1 root      1209695 Apr 16 15:33 vmunix.old
  232. X-rwxr-xr-x  1 root      1209702 May 14 19:04 vmunix
  233. X-rwxr-xr-x  1 root      1209758 May 21 12:23 vmunix.new.kernelmap.old
  234. X-rwxr-xr-x  1 root      1711848 Dec 26 20:08 vmunix.org
  235. X% cd
  236. X% alias rable='ls -AFtrd *(R)' nrable='ls -AFtrd *(^R)'
  237. X% rable
  238. XREADME      func/       bin/        pub/        News/       src/
  239. Xnicecolors  etc/        scr/        tmp/        iris/       zsh*
  240. X% nrable
  241. XMailboxes/  mail/       notes
  242. X
  243. X
  244. X(The pattern *(R) matches all readable files in the  current
  245. Xdirectory, and *(^R) matches all unreadable files.)
  246. X
  247. XMost  other  shells  have  aliases  of  this  kind  (command
  248. Xaliases).   However,  zsh also has global aliases, which are
  249. Xsubstituted anywhere on a line.  Global aliases can be  used
  250. Xto abbreviate frequently-typed usernames, hostnames, etc.
  251. X
  252. X% alias -g me=pfalstad gun=egsirer mjm=maruchck
  253. X% who | grep me
  254. Xpfalstad ttyp0   May 24 03:39   (mickey.Princeton)
  255. Xpfalstad ttyp5   May 24 03:42   (mickey.Princeton)
  256. X% fm gun
  257. XLogin name: egsirer                     In real life: Emin Gun Sirer
  258. XDirectory: /u/egsirer                   Shell: /bin/sh
  259. XLast login Thu May 23 19:05 on ttyq3 from bow.Princeton.ED
  260. XNew mail received Fri May 24 02:30:28 1991;
  261. X  unread since Fri May 24 02:30:27 1991
  262. X% alias -g phx=phoenix.princeton.edu warc=wuarchive.wustl.edu
  263. X% ftp warc
  264. XConnected to wuarchive.wustl.edu.
  265. X
  266. X
  267. XHere are some more interesting uses.
  268. X
  269. X% alias -g M='| more' GF='| fgrep -f ~/.friends'
  270. X% who M   # pipes the output of who through more
  271. X% who GF  # see if your friends are on
  272. X% w GF    # see what your friends are doing
  273. X
  274. X
  275. XAnother example makes use of zsh's process substitution.  If
  276. Xyou run NIS, and you miss being able to do this:
  277. X
  278. X% grep pfalstad /etc/passwd
  279. X
  280. X
  281. X
  282. X
  283. X
  284. X
  285. X
  286. X                           - 19 -
  287. Xyou can define an alias that will  seem  more  natural  than
  288. Xypmatch pfalstad passwd:
  289. X
  290. X% alias -g PASS='<(ypcat passwd)'
  291. X% grep pfalstad PASS
  292. Xpfalstad:*:3564:35:Paul John Falstad:/u/pfalstad:/usr/princeton/bin/zsh
  293. X
  294. X
  295. XIf you're really crazy, you can even call it /etc/passwd:
  296. X
  297. X% alias -g /etc/passwd='<(ypcat passwd)'
  298. X% grep pfalstad /etc/passwd
  299. Xpfalstad:*:3564:35:Paul John Falstad:/u/pfalstad:/usr/princeton/bin/zsh
  300. X
  301. X
  302. XThe last example shows one of the perils of global  aliases;
  303. Xthey  have a lot of potential to cause confusion.  For exam-
  304. Xple, if you defined a global alias called | (which is possi-
  305. Xble), zsh would begin to act very strangely; every pipe sym-
  306. Xbol would be replaced with the text of your alias.  To  some
  307. Xextent,  global  aliases are like macros in C; discretion is
  308. Xadvised in using them and in choosing names for them.  Using
  309. Xnames  in all caps is not a bad idea, especially for aliases
  310. Xwhich introduce shell metasyntax (like M and GF above).
  311. X
  312. XNote that zsh aliases are not like csh aliases.  The  syntax
  313. Xfor  defining  them is different, and they do not have argu-
  314. Xments.  All your favorite csh aliases will probably not work
  315. Xunder zsh.  For example, if you try:
  316. X
  317. Xalias rm mv '\!* /tmp/wastebasket'
  318. X
  319. X
  320. Xno aliases will be defined,  but  zsh  will  not  report  an
  321. Xerror.   In  csh,  this  line defines an alias that makes rm
  322. Xsafe---files that are rm'd will  be  moved  to  a  temporary
  323. Xdirectory  instead of instantly destroyed.  In zsh's syntax,
  324. Xhowever, this line asks the  shell  to  print  any  existing
  325. Xalias definitions for rm, mv, or !* /tmp/wastebasket.  Since
  326. Xthere are none, most likely, the shell will not  print  any-
  327. Xthing,  although alias will return a nonzero exit code.  The
  328. Xproper syntax is this:
  329. X
  330. Xalias rm='mv \!* /tmp/wastebasket'
  331. X
  332. X
  333. XHowever, this won't work either:
  334. X
  335. X% rm foo.dvi
  336. Xzsh: no matches found: !*
  337. X
  338. X
  339. XWhile this makes rm safe, it is certainly not what the  user
  340. Xintended.  In zsh, you must use a shell function for this:
  341. X
  342. X% unalias rm
  343. X% rm () { mv $* /tmp/wastebasket }
  344. X% rm foo.dvi
  345. X% ls /tmp/wastebasket
  346. Xfoo.dvi
  347. X
  348. X
  349. X
  350. X
  351. X
  352. X                           - 20 -
  353. XWhile this is much cleaner and easier to read  (I  hope  you
  354. Xwill  agree), it is not csh-compatible.  Therefore, a script
  355. Xto convert csh aliases and variables has been provided.  You
  356. Xshould  only  need  to  use it once, to convert all your csh
  357. Xaliases and parameters to zsh format:
  358. X
  359. X% csh
  360. Xcsh> alias
  361. Xl       ls -AF
  362. Xmore    less
  363. Xon      last -2 !:1 ; who | grep !:1
  364. Xcsh> exit
  365. X% c2z >neat_zsh_aliases
  366. X% cat neat_zsh_aliases
  367. Xalias l='ls -AF'
  368. Xalias more='less'
  369. Xon () { last -2 $1 ; who | grep $1 }
  370. X...
  371. X
  372. X
  373. XThe first two aliases were converted to regular zsh aliases,
  374. Xwhile  the  third,  since it needed to handle arguments, was
  375. Xconverted to a function.  c2z can convert  most  aliases  to
  376. Xzsh  format  without any problems.  However, if you're using
  377. Xsome really arcane csh tricks, or if you have an alias  with
  378. Xa  name  like do (which is reserved in zsh), you may have to
  379. Xfix some of the aliases by hand.
  380. X
  381. XThe c2z script checks your csh setup, and produces a list of
  382. Xzsh commands which replicate your aliases and parameter set-
  383. Xtings as closely as possible.  You could include its  output
  384. Xin your startup file, .zshrc.
  385. X
  386. XHistory
  387. X
  388. XThere are several ways to manipulate history  in  zsh.   One
  389. Xway is to use csh-style ! history:
  390. X
  391. X% /usr/local/bin/!:0 !-2*:s/foo/bar/ >>!$
  392. X
  393. X
  394. XIf you don't want to use this, you can turn it off by typing
  395. Xsetopt nobanghist.
  396. X
  397. XAnother way is to use the fc command.  For example,  if  you
  398. Xtype an erroneous command:
  399. X
  400. X% for i in `cat /etc/clients`
  401. X do
  402. X rpu $i
  403. X done
  404. Xzsh: command not found: rpu
  405. Xzsh: command not found: rpu
  406. Xzsh: command not found: rpu
  407. X
  408. X
  409. Xtyping fc will execute an editor on this  command,  allowing
  410. Xyou  to  fix it.  (The default editor is vi, by the way, not
  411. Xed).
  412. X
  413. X
  414. X
  415. X
  416. X
  417. X
  418. X                           - 21 -
  419. X
  420. X% fc
  421. X49
  422. X/rpu/s//rup/p
  423. X rup $i
  424. Xw
  425. X49
  426. Xq
  427. Xfor i in `cat /etc/clients`
  428. X do
  429. X rup $i
  430. X done
  431. X        beam    up  2 days, 10:17,    load average: 0.86, 0.80, 0.50
  432. X         bow    up  4 days,  8:41,    load average: 0.91, 0.80, 0.50
  433. X        burn    up          17:18,    load average: 0.91, 0.80, 0.50
  434. X       burst    up  9 days,  1:49,    load average: 0.95, 0.80, 0.50
  435. X         tan    up          11:14,    load average: 0.91, 0.80, 0.50
  436. X       bathe    up  3 days, 17:49,    load average: 1.84, 1.79, 1.50
  437. X        bird    up  1 day,   9:13,    load average: 1.95, 1.82, 1.51
  438. X      bonnet    up  2 days, 21:18,    load average: 0.93, 0.80, 0.50
  439. X
  440. X
  441. XA variant of the fc command is r, which redoes the last com-
  442. Xmand, with optional changes:
  443. X
  444. X% echo foo
  445. Xfoo
  446. X% r
  447. Xecho foo
  448. Xfoo
  449. X
  450. X% echo foo
  451. Xfoo
  452. X% r foo=bar
  453. Xecho bar
  454. Xbar
  455. X
  456. X
  457. X
  458. XCommand Line Editing
  459. X
  460. Xzsh's command line editor, ZLE, is quite  powerful.   It  is
  461. Xdesigned  to  emulate  either  emacs  or  vi; the default is
  462. Xemacs.  To set the bindings for vi mode, type bindkey -v.
  463. X
  464. XIn addition to basic editing, the shell allows you to recall
  465. Xprevious  lines in the history.  In emacs mode, this is done
  466. Xwith ^P (control-P):
  467. X
  468. X% ls ~
  469. X-           README      file        mail        pub         tmp
  470. XMailboxes   bin         func        nicecolors  scr         zsh
  471. XNews        etc         iris        notes       src
  472. X% echo foobar
  473. Xfoobar
  474. X% ^P
  475. X% echo foobar^P
  476. X% ls ~_
  477. X
  478. X
  479. X
  480. X
  481. X
  482. X
  483. X
  484. X                           - 22 -
  485. XPressing ^P once brings up the previous line (echo  foobar);
  486. Xpressing  it  again  brings  up the line before that (ls ~).
  487. XThe cursor is left at the end of the line, allowing  you  to
  488. Xedit  the  line  if  desired  before  executing it.  In many
  489. Xcases, ZLE eliminates the need for the fc command, since  it
  490. Xis powerful enough to handle even multiline commands:
  491. X
  492. X% for i in a b c d e
  493. X> do
  494. X> echo $i
  495. X> done
  496. Xa
  497. Xb
  498. Xc
  499. Xd
  500. Xe
  501. X% ^P
  502. X% for i in a b c d e
  503. X do
  504. X echo $i
  505. X done_
  506. X
  507. X
  508. XNow you can just move up to the part you want to change...
  509. X
  510. X% for i in _ b c d e
  511. X do
  512. X echo $i
  513. X done
  514. X
  515. X
  516. Xchange it, and execute the new command.
  517. X
  518. X% for i in f g h i j
  519. X do
  520. X echo $i
  521. X done
  522. Xf
  523. Xg
  524. Xh
  525. Xi
  526. Xj
  527. X
  528. X
  529. XAlso, you can search the history for a certain command using
  530. XESC-P:
  531. X
  532. X% set ESC-P
  533. X% setopt autolist ESC-P
  534. X% setopt nocorrect_
  535. X
  536. X
  537. XAnother way is to do an incremental search, emacs-style:
  538. X
  539. X
  540. X
  541. X
  542. X
  543. X
  544. X
  545. X
  546. X
  547. X
  548. X
  549. X
  550. X                           - 23 -
  551. X
  552. X% ^R
  553. X% _
  554. Xi-search:
  555. X
  556. X% l_ /usr/bin
  557. Xi-search: l
  558. X
  559. X% date > foofile_c
  560. Xi-search: le
  561. X
  562. X
  563. XAnother useful feature of the editor is command and filename
  564. Xcompletion.
  565. X
  566. X% compTAB
  567. X% compress _
  568. X
  569. X% ls /nicTAB
  570. X% ls /nicecolors _
  571. X
  572. X% ls /usr/prTAB
  573. X% ls /usr/princeton/_
  574. X
  575. X% ls -l =comTAB
  576. X% ls -l =compress _
  577. X
  578. X
  579. XIf the completion is ambiguous, the editor will  beep.   You
  580. Xcan list possible completions by pressing ^D:
  581. X
  582. X% ls /vmuTAB -beep-
  583. X% ls /vmunix_
  584. X% ls /vmunix^D
  585. Xvmunix                    vmunix.old
  586. Xvmunix.new.kernelmap.old  vmunix.org
  587. X
  588. X
  589. XOr, you could just set the AUTOLIST option:
  590. X
  591. X% setopt autolist
  592. X% ls /vmuTAB -beep-
  593. Xvmunix                    vmunix.old
  594. Xvmunix.new.kernelmap.old  vmunix.org
  595. X% ls /vmunix_
  596. X
  597. X
  598. XAnother option you could set is RECEXACT, which causes exact
  599. Xmatches  to  be  accepted,  even if there are other possible
  600. Xcompletions:
  601. X
  602. X% setopt recexact
  603. X% ls /vmuTAB -beep-
  604. Xvmunix                    vmunix.old
  605. Xvmunix.new.kernelmap.old  vmunix.org
  606. X% ls /vmunix_TAB
  607. X% ls /vmunix _
  608. X
  609. X
  610. XThe fignore variable  lists  suffixes  of  files  to  ignore
  611. X
  612. X
  613. X
  614. X
  615. X
  616. X                           - 24 -
  617. Xduring completion.
  618. X
  619. X% ls fooTAB -beep-
  620. Xfoofile.c  foofile.o
  621. X% fignore=( .o \~ .bak .junk )
  622. X% ls fooTAB
  623. X% ls foofile.c _
  624. X
  625. X
  626. XSince foofile.o has a suffix that is in the fignore list, it
  627. Xwas not considered a possible completion of foo.
  628. X
  629. XUsername completion is also supported:
  630. X
  631. X% ls ~pfalTAB
  632. X% ls ~pfalstad/_
  633. X
  634. X
  635. Xand parameter name completion:
  636. X
  637. X% echo $ORGTAB
  638. X% echo $ORGANIZATION _
  639. X
  640. X
  641. Xand hostname completion, if you give the  shell  a  list  of
  642. Xhosts to complete:
  643. X
  644. X% hosts=( phoenix.princeton.edu uunet.uu.net nic.ddn.mil
  645. X> diskfarm.princeton.edu gnu.ai.mit.edu
  646. X> eniac.seas.upenn.edu )
  647. X% telnet diskTAB
  648. X% telnet diskfarm.princeton.edu _
  649. X
  650. X% ftp uuTAB
  651. X% ftp uunet.uu.net _
  652. X
  653. X% mail subbarao@phTAB
  654. X% mail subbarao@phoenix.princeton.edu _
  655. X
  656. X
  657. Xand option completion:
  658. X
  659. X% setopt noclTAB
  660. X% setopt noclobber _
  661. X
  662. X
  663. Xand binding completion:
  664. X
  665. X% bindkey '^X^X' puTAB
  666. X% bindkey '^X^X' push-line _
  667. X
  668. X
  669. X
  670. XThe compctl command is used to control how completion works.
  671. XFor example, to specify that certain commands show take com-
  672. Xmands as arguments, you use compctl -c:
  673. X
  674. X% compctl -c man nohup
  675. X% man uptTAB
  676. X% man uptime _
  677. X
  678. X
  679. X
  680. X
  681. X
  682. X                           - 25 -
  683. XTo specify that a command  should  complete  filenames,  you
  684. Xshould use compctl -f.  This is the default.  It can be com-
  685. Xbined with -c, as well.
  686. X
  687. X% compctl -cf echo
  688. X% echo uptTAB
  689. X% echo uptime _
  690. X
  691. X% echo foTAB
  692. X% echo foo.c
  693. X
  694. X
  695. XSimilarly, use  -h  to  specify  hostnames,  -o  to  specify
  696. Xoptions,  -v  to  specify variables, and -b to specify bind-
  697. Xings.
  698. X
  699. X% compctl -h rlogin
  700. X% compctl -hfc rsh
  701. X% compctl -b bindkey
  702. X
  703. X
  704. XYou can also use -k to specify a custom list of keywords  to
  705. Xuse in completion.
  706. X
  707. X% ftphosts=(ftp.uu.net wuarchive.wustl.edu)
  708. X% compctl -k ftphosts ftp
  709. X% ftp wuTAB
  710. X% ftp wuarchive.wustl.edu _
  711. X
  712. X% friends=(cpirazzi subbarao sukthnkr)
  713. X% compctl -k friends mail finger su
  714. X% finger cpTAB
  715. X% finger cpirazzi _
  716. X
  717. X
  718. X
  719. XIn addition to completion, TAB performs expansion if  possi-
  720. Xble.
  721. X
  722. X% ls *.cTAB
  723. X% ls foofile.c fortune.c rnd.c strfile.c unstr.c_
  724. X
  725. X
  726. XFor example, suppose you have a bunch of weird files  in  an
  727. Ximportant directory:
  728. X
  729. X% ls
  730. X  * * *       ; & % $??foo  dspfok        foo.c
  731. X  !"foo"!       ` \ `         foo           rrr
  732. X
  733. X
  734. XYou want to remove them, but you don't want to damage foo.c.
  735. XHere is one way to do this:
  736. X
  737. X% rm *TAB
  738. X% rm \ \ \*\ \*\ \*\ \ \  \!\"foo\"\! \;\ \&\ %\ \$'
  739. X'foo \`\ \\\ \` dspfok foo foo.c rrr_
  740. X
  741. X
  742. XWhen you expand *, zsh inserts the names of  all  the  files
  743. X
  744. X
  745. X
  746. X
  747. X
  748. X                           - 26 -
  749. Xinto  the  editing  buffer, with proper shell quoting.  Now,
  750. Xjust move back and remove foo.c from the buffer:
  751. X
  752. X% rm \ \ \*\ \*\ \*\ \ \  \!\"foo\"\! \;\ \&\ %\ \$'
  753. X'foo \`\ \\\ \` dspfok foo _rr
  754. X
  755. X
  756. Xand press return.  Everything except foo.c will  be  deleted
  757. Xfrom the directory.
  758. X
  759. XHere's another trick; let's say you have typed this  command
  760. Xin:
  761. X
  762. X% gcc -o x.out foob.c -g -Wpointer-arith -Wtrigraphs_
  763. X
  764. X
  765. Xand you forget which library you want.  You need  to  escape
  766. Xout  for  a  minute and check by typing ls /usr/lib, or some
  767. Xother such command; but you don't want to retype  the  whole
  768. Xcommand  again,  and  you can't press return now because the
  769. Xcurrent command is incomplete.  In zsh, you can put the line
  770. Xon  the  buffer stack, using ESC-Q, and type some other com-
  771. Xmands.  The next time a prompt is printed, the gcc line will
  772. Xbe  popped  off  the  stack  and  put  in the editing buffer
  773. Xautomatically; you can then enter the  proper  library  name
  774. Xand  press  return  (or, ESC-Q again and look for some other
  775. Xlibraries whose names you forgot).
  776. X
  777. XA similar situation: what if you forget the  option  to  gcc
  778. Xthat  finds  bugs using AI techniques?  You could either use
  779. XESC-Q again, and type man gcc, or  you  could  press  ESC-H,
  780. Xwhich  essentially  does the same thing; it puts the current
  781. Xline on the buffer stack, and executes the command  run-help
  782. Xgcc, where run-help is an alias for man.
  783. X
  784. XAnother interesting command is  ESC-A.   This  executes  the
  785. Xcurrent  line,  but  retains  it  in  the buffer, so that it
  786. Xappears again when the next prompt is  printed.   Also,  the
  787. Xcursor  stays in the same place.  This is useful for execut-
  788. Xing a series of similar commands:
  789. X
  790. X% cc grok.c -g -lc -lgl -lsun -lmalloc -Bstatic -o b.out
  791. X% cc fubar.c -g -lc -lgl -lsun -lmalloc -Bstatic -o b.out
  792. X% cc fooble.c -g -lc -lgl -lsun -lmalloc -Bstatic -o b.out
  793. X
  794. X
  795. X
  796. XThe ESC-' command is useful for managing the shell's quoting
  797. Xconventions.  Let's say you want to print this string:
  798. X
  799. Xdon't do that; type 'rm -rf \*', with a \ before the *.
  800. X
  801. X
  802. XAll that is necessary is to type it into the editing buffer:
  803. X
  804. X% don't do that; type 'rm -rf \*', with a \ before the *.
  805. X
  806. X
  807. Xpress ESC-' (escape-quote):
  808. X
  809. X
  810. X
  811. X
  812. X
  813. X
  814. X                           - 27 -
  815. X
  816. X% 'don'\''t do that; type '\''rm -rf \*'\'', with a \ before the *.'
  817. X
  818. X
  819. Xthen move to the beginning and add the echo command.
  820. X
  821. X% echo 'don'\''t do that; type '\''rm -rf \*'\'', with a \ before the *.'
  822. Xdon't do that; type 'rm -rf \*', with a \ before the *.
  823. X
  824. X
  825. XLet's say you want to create an alias to do this  echo  com-
  826. Xmand.   This  can  be done by recalling the line with ^P and
  827. Xpressing ESC-' again:
  828. X
  829. X% 'echo '\''don'\''\'\'''\''t do that; type '\''\'\'''\''rm -rf
  830. X\*'\''\'\'''\'', with a \ before the *.'\'''
  831. X
  832. X
  833. Xand then move to the beginning and add the command to create
  834. Xan alias.
  835. X
  836. X% alias zoof='echo '\''don'\''\'\'''\''t do that; type '\''\'\'''\''rm
  837. X-rf \*'\''\'\'''\'', with a \ before the *.'\'''
  838. X% zoof
  839. Xdon't do that; type 'rm -rf \*', with a \ before the *.
  840. X
  841. X
  842. X
  843. XAnother interesting option is  MENUCOMPLETE.   This  affects
  844. Xthe way TAB works.  Let's look at the /vmunix example again:
  845. X
  846. X% setopt menucomplete
  847. X% ls /vmuTAB
  848. X% ls /vmunixTAB
  849. X% ls /vmunix.new.kernelmap.oldTAB
  850. X% ls /vmunix.old_
  851. X
  852. X
  853. XEach time you press TAB, it displays the next possible  com-
  854. Xpletion.   In  this  way, you can cycle through the possible
  855. Xcompletions until you find the one you want.
  856. X
  857. XThe AUTOMENU option makes a  nice  compromise  between  this
  858. Xmethod  of  completion  and  the regular method.  If you set
  859. Xthis option, pressing the TAB key repeatedly after an  ambi-
  860. Xguous  completion  will  cycle  through the possible comple-
  861. Xtions.
  862. X
  863. XBindings
  864. X
  865. XEach of the above editor commands was  actually  a  function
  866. Xbound  by  default  to a certain key.  The real names of the
  867. Xcommands are:
  868. X
  869. Xexpand-or-complete   TAB
  870. Xpush-line            ESC-Q
  871. Xrun-help             ESC-H
  872. Xaccept-and-hold      ESC-A
  873. Xquote-line           ESC-'
  874. X
  875. X
  876. X
  877. X
  878. X
  879. X
  880. X                           - 28 -
  881. XThese bindings are arbitrary; you could change them  if  you
  882. Xwant.  For example, to bind accept-line to ^Z:
  883. X
  884. X% bindkey '^Z' accept-line
  885. X
  886. X
  887. XAnother idea would be to bind the delete key to delete-char;
  888. Xthis might be convenient if you use ^H for backspace.
  889. X
  890. X% bindkey '^?' delete-char
  891. X
  892. X
  893. XOr, you could bind ^X^H to run-help:
  894. X
  895. X% bindkey '^X^H' run-help
  896. X
  897. X
  898. XOther examples:
  899. X
  900. X% bindkey '^X^Z' universal-argument
  901. X% bindkey ' ' magic-space
  902. X% bindkey -s '^T' 'uptime
  903. X> '
  904. X
  905. X
  906. Xuniversal-argument multiplies the next command by  4.   Thus
  907. X^X^Z^W might delete the last four words on the line.  If you
  908. Xbind space to magic-space, then csh-style history  expansion
  909. Xis done on the line whenever you press the space bar.
  910. X
  911. XThe -s flag to bindkey specifies that you  are  binding  the
  912. Xkey  to  a  string,  not  a  command.   Thus bindkey -s '^T'
  913. X'uptime\n' lets you VMS lovers get the load average whenever
  914. Xyou press ^T.
  915. X
  916. XIf you have a NeXT keyboard, the one with the | and  \  keys
  917. Xvery  inconveniently placed, the following bindings may come
  918. Xin handy:
  919. X
  920. X% bindkey -s '\e/' '\\'
  921. X% bindkey -s '\e=' '|'
  922. X
  923. X
  924. XNow you can type ALT-/ to get a backslash, and ALT-= to  get
  925. Xa  vertical  bar.   This  only  works inside zsh, of course;
  926. Xbindkey has no effect on the key  mappings  inside  talk  or
  927. Xmail, etc.
  928. X
  929. XAnother use of the editor is to edit the value of variables.
  930. XFor  example,  an easy way to change your path is to use the
  931. Xvared command:
  932. X
  933. X% vared PATH
  934. X> /u/pfalstad/scr:/u/pfalstad/bin/sun4:/u/maruchck/scr:/u/subbarao/bin:/u/maruc
  935. Xhck/bin:/u/subbarao/scripts:/usr/princeton/bin:/usr/ucb:/usr/bin:/bin:/usr/host
  936. Xs:/usr/princeton/bin/X11:/./usr/lang:/./usr/etc:/./etc
  937. X
  938. X
  939. XYou can now edit the path.  When you press return, the  con-
  940. Xtents of the edit buffer will be assigned to PATH.
  941. X
  942. X
  943. X
  944. X
  945. X
  946. X                           - 29 -
  947. XParameter Substitution
  948. X
  949. XIn zsh, parameters are set like this:
  950. X
  951. X% foo=bar
  952. X% echo $foo
  953. Xbar
  954. X
  955. X
  956. XSpaces before or after the = are frowned upon:
  957. X
  958. X% foo = bar
  959. Xzsh: command not found: foo
  960. X
  961. X
  962. XAlso, set doesn't work for setting parameters:
  963. X
  964. X% set foo=bar
  965. X% set foo = bar
  966. X% echo $foo
  967. X
  968. X%
  969. X
  970. X
  971. XNote that no error message was  printed.   This  is  because
  972. Xboth of these commands were perfectly valid; the set builtin
  973. Xassigns its arguments to the positional parameters ($1,  $2,
  974. Xetc.).
  975. X
  976. X% set foo=bar
  977. X% echo $1
  978. Xfoo=bar
  979. X% set foo = bar
  980. X% echo $3 $2
  981. Xbar =
  982. X
  983. X
  984. XIf you're really intent on using the csh  syntax,  define  a
  985. Xfunction like this:
  986. X
  987. X% set () {
  988. X>    eval "$1$2$3"
  989. X> }
  990. X% set foo = bar
  991. X% set fuu=brrr
  992. X% echo $foo $fuu
  993. Xbar brrr
  994. X
  995. X
  996. XBut then, of course you can't  use  the  form  of  set  with
  997. Xoptions,  like set -F (which turns off filename generation).
  998. XAlso, the set command by itself won't list all  the  parame-
  999. Xters  like  it  should.   To get around that you need a case
  1000. Xstatement:
  1001. X
  1002. X
  1003. X
  1004. X
  1005. X
  1006. X
  1007. X
  1008. X
  1009. X
  1010. X
  1011. X
  1012. X                           - 30 -
  1013. X
  1014. X% set () {
  1015. X>    case $1 in
  1016. X>    -*|+*|'') builtin set $* ;;
  1017. X>    *) eval "$1$2$3" ;;
  1018. X>    esac
  1019. X> }
  1020. X
  1021. X
  1022. XFor the most part, this should make csh users happy.
  1023. X
  1024. XThe following sh-style operators are supported in zsh:
  1025. X
  1026. X% unset null
  1027. X% echo ${foo-xxx}
  1028. Xbar
  1029. X% echo ${null-xxx}
  1030. Xxxx
  1031. X% unset null
  1032. X% echo ${null=xxx}
  1033. Xxxx
  1034. X% echo $null
  1035. Xxxx
  1036. X% echo ${foo=xxx}
  1037. Xbar
  1038. X% echo $foo
  1039. Xbar
  1040. X% unset null
  1041. X% echo ${null+set}
  1042. X
  1043. X% echo ${foo+set}
  1044. Xset
  1045. X
  1046. X
  1047. XAlso, csh-style : modifiers may be appended to  a  parameter
  1048. Xsubstitution.
  1049. X
  1050. X% echo $PWD
  1051. X/home/learning/pf/zsh/zsh2.00/src
  1052. X% echo $PWD:h
  1053. X/home/learning/pf/zsh/zsh2.00
  1054. X% echo $PWD:h:h
  1055. X/home/learning/pf/zsh
  1056. X% echo $PWD:t
  1057. Xsrc
  1058. X% name=foo.c
  1059. X% echo $name
  1060. Xfoo.c
  1061. X% echo $name:r
  1062. Xfoo
  1063. X% echo $name:e
  1064. Xc
  1065. X
  1066. X
  1067. XThe equivalent constructs in ksh (which are  also  supported
  1068. Xin zsh) are a bit more general and easier to remember.  When
  1069. Xthe shell expands  ${foo#pat},  it  checks  to  see  if  pat
  1070. Xmatches  a  substring  at the beginning of the value of foo.
  1071. XIf so, it removes that portion of foo,  using  the  shortest
  1072. Xpossible  match.   With  ${foo##pat},  the  longest possible
  1073. X
  1074. X
  1075. X
  1076. X
  1077. X
  1078. X                           - 31 -
  1079. Xmatch is removed.  ${foo%pat}  and  ${foo%%pat}  remove  the
  1080. Xmatch  from  the end.  Here are the ksh equivalents of the :
  1081. Xmodifiers:
  1082. X
  1083. X% echo ${PWD%/*}
  1084. X/home/learning/pf/zsh/zsh2.00
  1085. X% echo ${PWD%/*/*}
  1086. X/home/learning/pf/zsh
  1087. X% echo ${PWD##*/}
  1088. Xsrc
  1089. X% echo ${name%.*}
  1090. Xfoo
  1091. X% echo ${name#*.}
  1092. Xc
  1093. X
  1094. X
  1095. Xzsh also has upper/lowercase modifiers:
  1096. X
  1097. X% xx=Test
  1098. X% echo $xx:u
  1099. XTEST
  1100. X% echo $xx:l
  1101. Xtest
  1102. X
  1103. X
  1104. Xand a substitution modifier:
  1105. X
  1106. X% echo $name:s/foo/bar/
  1107. Xbar.c
  1108. X% ls
  1109. Xfoo.c    foo.h    foo.o    foo.pro
  1110. X% for i in foo.*; mv $i $i:s/foo/bar/
  1111. X% ls
  1112. Xbar.c    bar.h    bar.o    bar.pro
  1113. X
  1114. X
  1115. XOne possible source of confusion is the fact  that  in  zsh,
  1116. Xthe  result  of  parameter  substitution  is  not split into
  1117. Xwords.  Thus, this will not work:
  1118. X
  1119. X% srcs='glob.c exec.c init.c'
  1120. X% ls $srcs
  1121. Xglob.c exec.c init.c not found
  1122. X
  1123. X
  1124. XThis is considered a feature, not a bug.  If splitting  were
  1125. Xdone  by  default,  as it is in most other shells, functions
  1126. Xlike this would not work properly:
  1127. X
  1128. X$ ll () { ls -F $* }
  1129. X$ ll 'fuu bar'
  1130. Xfuu not found
  1131. Xbar not found
  1132. X
  1133. X% ll 'fuu bar'
  1134. Xfuu bar not found
  1135. X
  1136. X
  1137. XOf course, a hackish workaround  is  available  in  sh  (and
  1138. Xzsh):
  1139. X
  1140. X
  1141. X
  1142. X
  1143. X
  1144. X                           - 32 -
  1145. X
  1146. X% setopt shwordsplit
  1147. X% ll () { ls -F "$@" }
  1148. X% ll 'fuu bar'
  1149. Xfuu bar not found
  1150. X
  1151. X
  1152. XIf you like the sh behaviour, zsh can accomodate you:
  1153. X
  1154. X% ls ${=srcs}
  1155. Xexec.c  glob.c  init.c
  1156. X% setopt shwordsplit
  1157. X% ls $srcs
  1158. Xexec.c  glob.c  init.c
  1159. X
  1160. X
  1161. XAnother way to get the $srcs trick to  work  is  to  use  an
  1162. Xarray:
  1163. X
  1164. X% unset srcs
  1165. X% srcs=( glob.c exec.c init.c )
  1166. X% ls $srcs
  1167. Xexec.c  glob.c  init.c
  1168. X
  1169. X
  1170. Xor an alias:
  1171. X
  1172. X% alias -g SRCS='exec.c glob.c init.c'
  1173. X% ls SRCS
  1174. Xexec.c  glob.c  init.c
  1175. X
  1176. X
  1177. XAnother option that modifies parameter  expansion  is  RCEX-
  1178. XPANDPARAM:
  1179. X
  1180. X% echo foo/$srcs
  1181. Xfoo/glob.c exec.c init.c
  1182. X% setopt rcexpandparam
  1183. X% echo foo/$srcs
  1184. Xfoo/glob.c foo/exec.c foo/init.c
  1185. X% echo foo/${^srcs}
  1186. Xfoo/glob.c foo/exec.c foo/init.c
  1187. X% echo foo/$^srcs
  1188. Xfoo/glob.c foo/exec.c foo/init.c
  1189. X
  1190. X
  1191. X
  1192. XShell Parameters
  1193. X
  1194. XThe  shell  has  many  predefined  parameters  that  may  be
  1195. Xaccessed.  Here are some examples:
  1196. X
  1197. X
  1198. X
  1199. X
  1200. X
  1201. X
  1202. X
  1203. X
  1204. X
  1205. X
  1206. X
  1207. X
  1208. X
  1209. X
  1210. X                           - 33 -
  1211. X
  1212. X% sleep 10 &
  1213. X[1] 3820
  1214. X% echo $!
  1215. X3820
  1216. X% set a b c
  1217. X% echo $#
  1218. X3
  1219. X% echo $ARGC
  1220. X3
  1221. X% ( exit 20 ) ; echo $?
  1222. X20
  1223. X% false; echo $status
  1224. X1
  1225. X
  1226. X
  1227. X($? and $status are equivalent.)
  1228. X
  1229. X% echo $HOST $HOSTTYPE
  1230. Xdendrite sun4
  1231. X% echo $UID $GID
  1232. X701 60
  1233. X% cd /tmp
  1234. X% cd /home
  1235. X% echo $PWD $OLDPWD
  1236. X/home /tmp
  1237. X% ls $OLDPWD/.getwd
  1238. X/tmp/.getwd
  1239. X
  1240. X
  1241. X~+ and ~- are short for $PWD and $OLDPWD, respectively.
  1242. X
  1243. X% ls ~-/.getwd
  1244. X/tmp/.getwd
  1245. X% ls -d ~+/learning
  1246. X/home/learning
  1247. X% echo $RANDOM
  1248. X4880
  1249. X% echo $RANDOM
  1250. X11785
  1251. X% echo $RANDOM
  1252. X2062
  1253. X% echo $TTY
  1254. X/dev/ttyp4
  1255. X% echo $VERSION
  1256. Xzsh v2.00.03
  1257. X% echo $USERNAME
  1258. Xpf
  1259. X
  1260. X
  1261. X
  1262. XThe cdpath variable sets the search path for the cd command.
  1263. XIf you do not specify . somewhere in the path, it is assumed
  1264. Xto be the first component.
  1265. X
  1266. X
  1267. X
  1268. X
  1269. X
  1270. X
  1271. X
  1272. X
  1273. X
  1274. X
  1275. X
  1276. X                           - 34 -
  1277. X
  1278. X% cdpath=( /usr ~ ~/zsh )
  1279. X% ls /usr
  1280. X5bin         dict         lang         net          sccs         sys
  1281. X5include     etc          lector       nserve       services     tmp
  1282. X5lib         export       lib          oed          share        ucb
  1283. Xadm          games        local        old          skel         ucbinclude
  1284. Xbin          geac         lost+found   openwin      spool        ucblib
  1285. Xboot         hosts        macsyma_417  pat          src          xpg2bin
  1286. Xdemo         include      man          princeton    stand        xpg2include
  1287. Xdiag         kvm          mdec         pub          swap         xpg2lib
  1288. X% cd spool
  1289. X/usr/spool
  1290. X% cd bin
  1291. X/usr/bin
  1292. X% cd func
  1293. X~/func
  1294. X% cd
  1295. X% cd pub
  1296. X% pwd
  1297. X/u/pfalstad/pub
  1298. X% ls -d /usr/pub
  1299. X/usr/pub
  1300. X
  1301. X
  1302. XPATH and path both set the search path for commands.   These
  1303. Xtwo  variables  are  equivalent, except that one is a string
  1304. Xand one is an array.  If the user modifies PATH,  the  shell
  1305. Xchanges path as well, and vice versa.
  1306. X
  1307. X% PATH=/bin:/usr/bin:/tmp:.
  1308. X% echo $path
  1309. X/bin /usr/bin /tmp .
  1310. X% path=( /usr/bin . /usr/local/bin /usr/ucb )
  1311. X% echo $PATH
  1312. X/usr/bin:.:/usr/local/bin:/usr/ucb
  1313. X
  1314. X
  1315. XThe same is true of CDPATH and cdpath:
  1316. X
  1317. X% echo $CDPATH
  1318. X/usr:/u/pfalstad:/u/pfalstad/zsh
  1319. X% CDPATH=/u/subbarao:/usr/src:/tmp
  1320. X% echo $cdpath
  1321. X/u/subbarao /usr/src /tmp
  1322. X
  1323. X
  1324. XIn general, parameters  with  names  in  all  lowercase  are
  1325. Xarrays; assignments to them take the form:
  1326. X
  1327. Xname=( elem ... )
  1328. X
  1329. X
  1330. XParameters with names in  all  uppercase  are  strings.   If
  1331. Xthere  is  both  an  array  and a string version of the same
  1332. Xparameter, the string version  is  a  colon-separated  list,
  1333. Xlike PATH.
  1334. X
  1335. XHISTFILE is the name of the history file, where the  history
  1336. Xis saved when a shell exits.
  1337. X
  1338. X
  1339. X
  1340. X
  1341. X
  1342. X                           - 35 -
  1343. X
  1344. X% zsh
  1345. Xphoenix% HISTFILE=/tmp/history
  1346. Xphoenix% SAVEHIST=20
  1347. Xphoenix% echo foo
  1348. Xfoo
  1349. Xphoenix% date
  1350. XFri May 24 05:39:35 EDT 1991
  1351. Xphoenix% uptime
  1352. X  5:39am  up 4 days, 20:02,  40 users,  load average: 2.30, 2.20, 2.00
  1353. Xphoenix% exit
  1354. X% cat /tmp/history
  1355. XHISTFILE=/tmp/history
  1356. XSAVEHIST=20
  1357. Xecho foo
  1358. Xdate
  1359. Xuptime
  1360. Xexit
  1361. X% HISTSIZE=3
  1362. X% history
  1363. X   28  rm /tmp/history
  1364. X   29  HISTSIZE=3
  1365. X   30  history
  1366. X
  1367. X
  1368. X
  1369. XIn zsh, if you say
  1370. X
  1371. X% >file
  1372. X
  1373. X
  1374. Xthe command cat is normally assumed:
  1375. X
  1376. X% >file
  1377. Xfoo!
  1378. X^D
  1379. X% cat file
  1380. Xfoo!
  1381. X
  1382. X
  1383. XThus, you can view a file simply by typing:
  1384. X
  1385. X% <file
  1386. Xfoo!
  1387. X
  1388. X
  1389. XHowever, this is not csh or sh compatible.  To correct this,
  1390. Xchange  the  value of the parameter NULLCMD, which is cat by
  1391. Xdefault.
  1392. X
  1393. X% NULLCMD=:
  1394. X% >file
  1395. X% ls -l file
  1396. X-rw-r--r--  1 pfalstad        0 May 24 05:41 file
  1397. X
  1398. X
  1399. XIf NULLCMD is unset, the shell reports an error if  no  com-
  1400. Xmand is specified (like csh).
  1401. X
  1402. X
  1403. X
  1404. X
  1405. X
  1406. X
  1407. X
  1408. X                           - 36 -
  1409. X
  1410. X% unset NULLCMD
  1411. X% >file
  1412. Xzsh: redirection with no command
  1413. X
  1414. X
  1415. XActually, READNULLCMD is used whenever you have a null  com-
  1416. Xmand  reading  input  from a single file.  Thus, you can set
  1417. XREADNULLCMD to more or less rather than cat.  Also,  if  you
  1418. Xset  NULLCMD  to  : for sh compatibility, you can still read
  1419. Xfiles with < file if you leave READNULLCMD set to more.
  1420. X
  1421. XPrompting
  1422. X
  1423. XThe default prompt for zsh is:
  1424. X
  1425. Xphoenix% echo $PROMPT
  1426. X%m%#
  1427. X
  1428. X
  1429. XThe %m stands for the short form of  the  current  hostname,
  1430. Xand  the  %# stands for a % or a #, depending on whether the
  1431. Xshell is running as root or not.  zsh  supports  many  other
  1432. Xcontrol sequences in the PROMPT variable.
  1433. X
  1434. X% PROMPT='%/> '
  1435. X/u/pfalstad/etc/TeX/zsh>
  1436. X
  1437. X% PROMPT='%~> '
  1438. X~/etc/TeX/zsh>
  1439. X
  1440. X% PROMPT='%h %~> '
  1441. X6 ~/etc/TeX/zsh>
  1442. X
  1443. X
  1444. X%h represents the number of current history event.
  1445. X
  1446. X% PROMPT='%h %~ %M> '
  1447. X10 ~/etc/TeX/zsh apple-gunkies.gnu.ai.mit.edu>
  1448. X
  1449. X% PROMPT='%h %~ %m> '
  1450. X11 ~/etc/TeX/zsh apple-gunkies>
  1451. X
  1452. X% PROMPT='%h %t> '
  1453. X12 6:11am>
  1454. X
  1455. X% PROMPT='%n %w tty%l>'
  1456. Xpfalstad Fri 24 ttyp0>
  1457. X
  1458. X
  1459. XAlso available is the RPROMPT parameter.  If  this  is  set,
  1460. Xthe shell puts a prompt on the right side of the screen.
  1461. X
  1462. X
  1463. X
  1464. X
  1465. X
  1466. X
  1467. X
  1468. X
  1469. X
  1470. X
  1471. X
  1472. X
  1473. X
  1474. X                           - 37 -
  1475. X
  1476. X% RPROMPT='%t'
  1477. X%                                                      6:14am
  1478. X
  1479. X% RPROMPT='%~'
  1480. X%                                               ~/etc/TeX/zsh
  1481. X
  1482. X% PROMPT='%l %T %m[%h] ' RPROMPT=' %~'
  1483. Xp0 6:15 phoenix[5]                              ~/etc/TeX/zsh
  1484. X
  1485. X
  1486. XThese special escape sequences can also be used with the  -P
  1487. Xoption to print:
  1488. X
  1489. X% print -P %h tty%l
  1490. X15 ttyp1
  1491. X
  1492. X
  1493. X
  1494. XThe POSTEDIT parameter is printed whenever the editor exits.
  1495. XThis  can  be  useful  for termcap tricks.  To highlight the
  1496. Xprompt  and  command  line  while  leaving  command   output
  1497. Xunhighlighted, try this:
  1498. X
  1499. X% POSTEDIT=`echotc se`
  1500. X% PROMPT='%S%% '
  1501. X
  1502. X
  1503. X
  1504. XLogin/logout watching
  1505. X
  1506. XYou can specify login or logout events to monitor by setting
  1507. Xthe  watch variable.  Normally, this is done by specifying a
  1508. Xlist of usernames.
  1509. X
  1510. X% watch=( pfalstad subbarao sukthnkr egsirer )
  1511. X
  1512. X
  1513. XThe log command reports all people logged in  that  you  are
  1514. Xwatching for.
  1515. X
  1516. X% log
  1517. Xpfalstad has logged on p0 from mickey.
  1518. Xpfalstad has logged on p5 from mickey.
  1519. X% ...
  1520. Xsubbarao has logged on p8 from phoenix.
  1521. X% ...
  1522. Xsubbarao has logged off p8 from phoenix.
  1523. X% ...
  1524. Xsukthnkr has logged on p8 from dew.
  1525. X% ...
  1526. Xsukthnkr has logged off p8 from dew.
  1527. X
  1528. X
  1529. XIf you specify hostnames with an @ prepended, the shell will
  1530. Xwatch for all users logging in from the specified host.
  1531. X
  1532. X
  1533. X
  1534. X
  1535. X
  1536. X
  1537. X
  1538. X
  1539. X
  1540. X                           - 38 -
  1541. X
  1542. X% watch=( @mickey @phoenix )
  1543. X% log
  1544. Xdjthongs has logged on q2 from phoenix.
  1545. Xpfalstad has logged on p0 from mickey.
  1546. Xpfalstad has logged on p5 from mickey.
  1547. X
  1548. X
  1549. XIf you give a tty name with a % prepended,  the  shell  will
  1550. Xwatch for all users logging in on that tty.
  1551. X
  1552. X% watch=( %ttyp0 %console )
  1553. X% log
  1554. Xroot has logged on console from .
  1555. Xpfalstad has logged on p0 from mickey.
  1556. X
  1557. X
  1558. XThe format of the reports may also be changed.
  1559. X
  1560. X
  1561. X
  1562. X
  1563. X
  1564. X
  1565. X
  1566. X
  1567. X
  1568. X
  1569. X
  1570. X
  1571. X
  1572. X
  1573. X
  1574. X
  1575. X
  1576. X
  1577. X
  1578. X
  1579. X
  1580. X
  1581. X
  1582. X
  1583. X
  1584. X
  1585. X
  1586. X
  1587. X
  1588. X
  1589. X
  1590. X
  1591. X
  1592. X
  1593. X
  1594. X
  1595. X
  1596. X
  1597. X
  1598. X
  1599. X
  1600. X
  1601. X
  1602. X
  1603. X
  1604. X
  1605. X
  1606. X                           - 39 -
  1607. X
  1608. X% watch=( pfalstad gettes eps djthongs jcorr bdavis )
  1609. X% log
  1610. Xjcorr has logged on tf from 128.112.176.3:0.
  1611. Xjcorr has logged on r0 from 128.112.176.3:0.
  1612. Xgettes has logged on p4 from yo:0.0.
  1613. Xdjthongs has logged on pe from grumpy:0.0.
  1614. Xdjthongs has logged on q2 from phoenix.
  1615. Xbdavis has logged on qd from BRUNO.
  1616. Xeps has logged on p3 from csx30:0.0.
  1617. Xpfalstad has logged on p0 from mickey.
  1618. Xpfalstad has logged on p5 from mickey.
  1619. X% WATCHFMT='%n on tty%l from %M'
  1620. X% log
  1621. Xjcorr on ttytf from 128.112.176.3:0.
  1622. Xjcorr on ttyr0 from 128.112.176.3:0.
  1623. Xgettes on ttyp4 from yo:0.0
  1624. Xdjthongs on ttype from grumpy:0.0
  1625. Xdjthongs on ttyq2 from phoenix.Princeto
  1626. Xbdavis on ttyqd from BRUNO.pppl.gov
  1627. Xeps on ttyp3 from csx30:0.0
  1628. Xpfalstad on ttyp0 from mickey.Princeton
  1629. Xpfalstad on ttyp5 from mickey.Princeton
  1630. X% WATCHFMT='%n fm %m'
  1631. X% log
  1632. Xjcorr fm 128.112.176.3:0
  1633. Xjcorr fm 128.112.176.3:0
  1634. Xgettes fm yo:0.0
  1635. Xdjthongs fm grumpy:0.0
  1636. Xdjthongs fm phoenix
  1637. Xbdavis fm BRUNO
  1638. Xeps fm csx30:0.0
  1639. Xpfalstad fm mickey
  1640. Xpfalstad fm mickey
  1641. X% WATCHFMT='%n %a at %t %w.'
  1642. X% log
  1643. Xjcorr logged on at 3:15pm Mon 20.
  1644. Xjcorr logged on at 3:16pm Wed 22.
  1645. Xgettes logged on at 6:54pm Wed 22.
  1646. Xdjthongs logged on at 7:19am Thu 23.
  1647. Xdjthongs logged on at 7:20am Thu 23.
  1648. Xbdavis logged on at 12:40pm Thu 23.
  1649. Xeps logged on at 4:19pm Thu 23.
  1650. Xpfalstad logged on at 3:39am Fri 24.
  1651. Xpfalstad logged on at 3:42am Fri 24.
  1652. X
  1653. X
  1654. XIf you have a .friends file in your home directory,  a  con-
  1655. Xvenient  way to make zsh watch for all your friends is to do
  1656. Xthis:
  1657. X
  1658. X% watch=( $(< ~/.friends) )
  1659. X% echo $watch
  1660. Xsubbarao maruchck root sukthnkr ...
  1661. X
  1662. X
  1663. XIf watch is set to all, then all users  logging  in  or  out
  1664. Xwill be reported.
  1665. X
  1666. X
  1667. X
  1668. X
  1669. X
  1670. X
  1671. X
  1672. X                           - 40 -
  1673. XOptions
  1674. X
  1675. XSome options have already been mentioned;  here  are  a  few
  1676. Xmore:
  1677. X
  1678. X% cd /
  1679. X% setopt autocd
  1680. X% bin
  1681. X% pwd
  1682. X/bin
  1683. X% ../etc
  1684. X% pwd
  1685. X/etc
  1686. X
  1687. X
  1688. XUsing the AUTOCD option, you can simply type the name  of  a
  1689. Xdirectory, and it will become the current directory.
  1690. X
  1691. X% setopt cdablevars
  1692. X% foo=/tmp
  1693. X% cd foo
  1694. X/tmp
  1695. X
  1696. X
  1697. XWith CDABLEVARS, if the argument to cd  is  the  name  of  a
  1698. Xparameter  whose  value is a valid directory, it will become
  1699. Xthe current directory.
  1700. X
  1701. XCORRECT turns on spelling correction for commands,  and  the
  1702. XCORRECTALL option turns on spelling correction for all argu-
  1703. Xments.
  1704. X
  1705. X% setopt correct
  1706. X% sl
  1707. Xzsh: correct `sl' to `ls' [nyae]? y
  1708. X% setopt correctall
  1709. X% ls x.v11r4
  1710. Xzsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
  1711. X/usr/princton/src/x.v11r4 not found
  1712. X% ls /etc/paswd
  1713. Xzsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
  1714. X/etc/passwd
  1715. X
  1716. X
  1717. XIf you press y when the  shell  asks  you  if  you  want  to
  1718. Xcorrect  a  word,  it will be corrected.  If you press n, it
  1719. Xwill be left alone.  Pressing  a  aborts  the  command,  and
  1720. Xpressing e brings the line up for editing again, in case you
  1721. Xagree the word is spelled  wrong  but  you  don't  like  the
  1722. Xcorrection.
  1723. X
  1724. XNormally, a quoted expression may contain a newline:
  1725. X
  1726. X% echo '
  1727. X> foo
  1728. X> '
  1729. X
  1730. Xfoo
  1731. X
  1732. X%
  1733. X
  1734. X
  1735. X
  1736. X
  1737. X
  1738. X                           - 41 -
  1739. XWith CSHJUNKIEQUOTES set, this is illegal, as it is in csh.
  1740. X
  1741. X% setopt cshjunkiequotes
  1742. X% ls 'foo
  1743. Xzsh: unmatched '
  1744. X
  1745. X
  1746. XGLOBDOTS lets files beginning with a .  be  matched  without
  1747. Xexplicitly specifying the dot.
  1748. X
  1749. X% ls -d *x*
  1750. XMailboxes
  1751. X% setopt globdots
  1752. X% ls -d *x*
  1753. X.exrc         .pnewsexpert  .xserverrc
  1754. X.mushexpert   .xinitrc      Mailboxes
  1755. X
  1756. X
  1757. XHISTIGNOREDUPS prevents the current line from being saved in
  1758. Xthe  history  if it is the same as the previous one; HISTIG-
  1759. XNORESPACE prevents the current line from being saved  if  it
  1760. Xbegins with a space.
  1761. X
  1762. X% PROMPT='%h> '
  1763. X39> setopt histignoredups
  1764. X40> echo foo
  1765. Xfoo
  1766. X41> echo foo
  1767. Xfoo
  1768. X41> echo foo
  1769. Xfoo
  1770. X41> echo bar
  1771. Xbar
  1772. X42> setopt histignorespace
  1773. X43>  echo foo
  1774. Xfoo
  1775. X43>  echo fubar
  1776. Xfubar
  1777. X43>  echo fubar
  1778. Xfubar
  1779. X
  1780. X
  1781. XIGNOREBRACES turns off csh-style brace expansion.
  1782. X
  1783. X% echo x{y{z,a},{b,c}d}e
  1784. Xxyze xyae xbde xcde
  1785. X% setopt ignorebraces
  1786. X% echo x{y{z,a},{b,c}d}e
  1787. Xx{y{z,a},{b,c}d}e
  1788. X
  1789. X
  1790. XIGNOREEOF forces the user to type exit or logout, instead of
  1791. Xjust pressing ^D.
  1792. X
  1793. X% setopt ignoreeof
  1794. X% ^D
  1795. Xzsh: use 'exit' to exit.
  1796. X
  1797. X
  1798. XINTERACTIVECOMMENTS turns on interactive comments;  comments
  1799. X
  1800. X
  1801. X
  1802. X
  1803. X
  1804. X                           - 42 -
  1805. Xbegin with a #.
  1806. X
  1807. X% setopt interactivecomments
  1808. X% date # this is a comment
  1809. XFri May 24 06:54:14 EDT 1991
  1810. X
  1811. X
  1812. XNOCLOBBER prevents  you  from  accidentally  overwriting  an
  1813. Xexisting file.
  1814. X
  1815. X% setopt noclobber
  1816. X% cat /dev/null >~/.zshrc
  1817. Xzsh: file exists: /u/pfalstad/.zshrc
  1818. X
  1819. X
  1820. XIf you really do want to clobber a file, you can use the  >!
  1821. Xoperator.   To  make  things  easier  in this case, the > is
  1822. Xstored in the history list as a >!:
  1823. X
  1824. X% cat /dev/null >! ~/.zshrc
  1825. X% cat /etc/motd > ~/.zshrc
  1826. Xzsh: file exists: /u/pfalstad/.zshrc
  1827. X% !!
  1828. Xcat /etc/motd >! ~/.zshrc
  1829. X% ...
  1830. X
  1831. X
  1832. XRCQUOTES lets you use a more elegant  method  for  including
  1833. Xsingle quotes in a singly quoted string:
  1834. X
  1835. X% echo '"don'\''t do that."'
  1836. X"don't do that."
  1837. X% echo '"don''t do that."'
  1838. X"dont do that."
  1839. X% setopt rcquotes
  1840. X% echo '"don''t do that."'
  1841. X"don't do that."
  1842. X
  1843. X
  1844. XFinally, SUNKEYBOARDHACK wins the award  for  the  strangest
  1845. Xoption.   If a line ends with `, and there are an odd number
  1846. Xof them on the line, the shell will ignore the  trailing  `.
  1847. XThis  is  provided  for  keyboards  whose  RETURN key is too
  1848. Xsmall, and too close to the ` key.
  1849. X
  1850. X% setopt sunkeyboardhack
  1851. X% date`
  1852. XFri May 24 06:55:38 EDT 1991
  1853. X
  1854. X
  1855. X
  1856. XClosing Comments
  1857. X
  1858. XI would be happy to receive mail if anyone has any tricks or
  1859. Xideas  to  add to this document, or if there are some points
  1860. Xthat could be  made  clearer  or  covered  more  thoroughly.
  1861. XPlease notify me of any errors in this document.
  1862. X
  1863. X
  1864. X
  1865. X
  1866. X
  1867. X
  1868. SHAR_EOF
  1869. echo 'File zsh2.2/doc/intro.txt is complete' &&
  1870. chmod 0644 zsh2.2/doc/intro.txt ||
  1871. echo 'restore of zsh2.2/doc/intro.txt failed'
  1872. Wc_c="`wc -c < 'zsh2.2/doc/intro.txt'`"
  1873. test 58603 -eq "$Wc_c" ||
  1874.     echo 'zsh2.2/doc/intro.txt: original size 58603, current size' "$Wc_c"
  1875. rm -f _shar_wnt_.tmp
  1876. fi
  1877. # ============= zsh2.2/dots/zlogin ==============
  1878. if test ! -d 'zsh2.2/dots'; then
  1879.     echo 'x - creating directory zsh2.2/dots'
  1880.     mkdir 'zsh2.2/dots'
  1881. fi
  1882. if test -f 'zsh2.2/dots/zlogin' -a X"$1" != X"-c"; then
  1883.     echo 'x - skipping zsh2.2/dots/zlogin (File already exists)'
  1884.     rm -f _shar_wnt_.tmp
  1885. else
  1886. > _shar_wnt_.tmp
  1887. echo 'x - extracting zsh2.2/dots/zlogin (Text)'
  1888. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/dots/zlogin' &&
  1889. Xclear
  1890. Xcd
  1891. Xstty dec new cr0 -tabs
  1892. Xttyctl -f  # freeze the terminal modes... can't change without a ttyctl -u
  1893. Xumask 022
  1894. Xexport MAIL=/usr/spool/mail/$USER
  1895. XMAILCHECK=60
  1896. Xmesg y
  1897. Xuptime
  1898. Xfortune
  1899. Xlog
  1900. Xfrom 2>/dev/null
  1901. Xcat notes
  1902. Xunlimit
  1903. Xlimit core 0
  1904. Xmsgs -fp
  1905. SHAR_EOF
  1906. chmod 0644 zsh2.2/dots/zlogin ||
  1907. echo 'restore of zsh2.2/dots/zlogin failed'
  1908. Wc_c="`wc -c < 'zsh2.2/dots/zlogin'`"
  1909. test 247 -eq "$Wc_c" ||
  1910.     echo 'zsh2.2/dots/zlogin: original size 247, current size' "$Wc_c"
  1911. rm -f _shar_wnt_.tmp
  1912. fi
  1913. # ============= zsh2.2/dots/zshrc ==============
  1914. if test -f 'zsh2.2/dots/zshrc' -a X"$1" != X"-c"; then
  1915.     echo 'x - skipping zsh2.2/dots/zshrc (File already exists)'
  1916.     rm -f _shar_wnt_.tmp
  1917. else
  1918. > _shar_wnt_.tmp
  1919. echo 'x - extracting zsh2.2/dots/zshrc (Text)'
  1920. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/dots/zshrc' &&
  1921. X#
  1922. X# my rc file for zsh 2.2
  1923. X# all this runs in interactive shells only
  1924. X#
  1925. X
  1926. X# search path for the cd command
  1927. Xcdpath=(. ~ ~/src/cs320 ~/src)
  1928. X
  1929. X# where to look for function definitions
  1930. X# fpath=(~/func)
  1931. X
  1932. X# useful directory
  1933. Xcsrc=/usr/princeton/common/src
  1934. X
  1935. X# use hard limits, except for a smaller stack and no core dumps
  1936. Xunlimit
  1937. Xlimit stack 8192
  1938. Xlimit core 0
  1939. Xlimit -s
  1940. X
  1941. Xumask 022
  1942. X
  1943. X# define some aliases
  1944. Xalias a=alias
  1945. Xa a.out=./a.out sendmail=/usr/lib/sendmail c=cp 0=vi 09='vi -t' 00=r
  1946. Xa d=dirs en='enscript -2rGh' fm='finger -m' grep=egrep h=history
  1947. Xa hinfo='host -t hinfo' j=jobs l='ls -AF' lock='lock -p -60000'
  1948. Xa lsd='ls -d */' m=make mm=less
  1949. Xa nrable='ls -AFltrd *(^R)' sz='ls -l | sort -n +3 | tail -20'
  1950. Xa sn='sed -n' nw='l -ltr | tail' pd=pushd pop=popd mroe=more
  1951. Xa rable='ls -AFltrd *(R)' strings='strings -' t=cat
  1952. Xa v=mv where='hostname; echo >/dev/null' k9='kill -9' whoami='echo root'
  1953. Xa find='noglob find' bindkey='noglob bindkey' dh='dirs -v'
  1954. Xa mv='nocorrect mv' z=suspend
  1955. X
  1956. X# global aliases
  1957. Xa -g 'GF'='| fgrep -f ~/.friends' G='| grep' M='| less' cex='/u/pup/centrex'
  1958. X
  1959. X# setenv for csh junkies (including tset)
  1960. Xsetenv() { export $1=$2 }
  1961. X
  1962. Xmanpath=(/usr/man /usr/princeton/man /u/cad/man /usr/lang/man)
  1963. Xexport MANPATH
  1964. X
  1965. X# filename completion suffixes to ignore
  1966. Xfignore=(.o .pro .old)
  1967. X
  1968. X# hosts to use for completion
  1969. Xhosts=(uunet.uu.net `hostname` wuarchive.wustl.edu quiche.cs.mcgill.ca)
  1970. X
  1971. XPROMPT='%l %T %m[%h] '
  1972. X
  1973. X# prompt on the right side of the screen
  1974. XRPROMPT=' %~'
  1975. X
  1976. X# some environment variables
  1977. Xexport MAILCALL='NEW MAIL! '
  1978. Xexport YOUSAID='In %C you wrote:'
  1979. Xexport ATTRIBUTION='%f wrote:'
  1980. X
  1981. X# functions to autoload
  1982. X# autoload cx acx mere yu yp randline proto namedir ilogin
  1983. X
  1984. XMAILCHECK=30
  1985. XHISTSIZE=600
  1986. XDIRSTACKSIZE=50
  1987. X
  1988. X# lots of options
  1989. Xsetopt notify globdots correct pushdtohome cdablevars autolist \
  1990. X    sunkeyboardhack correctall autocd recexact longlistjobs mailwarning \
  1991. X    autoresume histignoredups pushdsilent noclobber \
  1992. X    autopushd pushdminus extendedglob rcquotes
  1993. Xunsetopt bgnice
  1994. X
  1995. X# watch for my friends
  1996. Xwatch=($(cat ~/.friends))
  1997. XWATCHFMT='%n %a %l from %m at %t.'
  1998. XLOGCHECK=0
  1999. X
  2000. Xexport LESS=-ainx3
  2001. Xunhash p
  2002. X
  2003. X# some nice bindings
  2004. Xbindkey '^X^Z' universal-argument ' ' magic-space
  2005. Xbindkey '^X^A' vi-find-prev-char-skip
  2006. Xbindkey '^Z' accept-and-hold
  2007. Xbindkey -s '\M-/' \\\\
  2008. Xbindkey -s '\M-=' \|
  2009. SHAR_EOF
  2010. chmod 0644 zsh2.2/dots/zshrc ||
  2011. echo 'restore of zsh2.2/dots/zshrc failed'
  2012. Wc_c="`wc -c < 'zsh2.2/dots/zshrc'`"
  2013. test 2291 -eq "$Wc_c" ||
  2014.     echo 'zsh2.2/dots/zshrc: original size 2291, current size' "$Wc_c"
  2015. rm -f _shar_wnt_.tmp
  2016. fi
  2017. # ============= zsh2.2/dots/zshenv ==============
  2018. if test -f 'zsh2.2/dots/zshenv' -a X"$1" != X"-c"; then
  2019.     echo 'x - skipping zsh2.2/dots/zshenv (File already exists)'
  2020.     rm -f _shar_wnt_.tmp
  2021. else
  2022. > _shar_wnt_.tmp
  2023. echo 'x - extracting zsh2.2/dots/zshenv (Text)'
  2024. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/dots/zshenv' &&
  2025. Xpath=(~/scr ~/bin/$HOSTTYPE
  2026. X    /usr/princeton/bin /usr/ucb /usr/bin /bin
  2027. X    /usr/hosts /usr/princeton/bin/X11 /usr/etc /etc .)
  2028. SHAR_EOF
  2029. chmod 0644 zsh2.2/dots/zshenv ||
  2030. echo 'restore of zsh2.2/dots/zshenv failed'
  2031. Wc_c="`wc -c < 'zsh2.2/dots/zshenv'`"
  2032. test 123 -eq "$Wc_c" ||
  2033.     echo 'zsh2.2/dots/zshenv: original size 123, current size' "$Wc_c"
  2034. rm -f _shar_wnt_.tmp
  2035. fi
  2036. # ============= zsh2.2/func/acx ==============
  2037. if test ! -d 'zsh2.2/func'; then
  2038.     echo 'x - creating directory zsh2.2/func'
  2039.     mkdir 'zsh2.2/func'
  2040. fi
  2041. if test -f 'zsh2.2/func/acx' -a X"$1" != X"-c"; then
  2042.     echo 'x - skipping zsh2.2/func/acx (File already exists)'
  2043.     rm -f _shar_wnt_.tmp
  2044. else
  2045. > _shar_wnt_.tmp
  2046. echo 'x - extracting zsh2.2/func/acx (Text)'
  2047. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/acx' &&
  2048. X#! /bin/sh
  2049. X#
  2050. X# zsh shell function to make its arguments 755
  2051. X# also works as an sh script
  2052. X#
  2053. Xchmod 755 $*
  2054. SHAR_EOF
  2055. chmod 0755 zsh2.2/func/acx ||
  2056. echo 'restore of zsh2.2/func/acx failed'
  2057. Wc_c="`wc -c < 'zsh2.2/func/acx'`"
  2058. test 104 -eq "$Wc_c" ||
  2059.     echo 'zsh2.2/func/acx: original size 104, current size' "$Wc_c"
  2060. rm -f _shar_wnt_.tmp
  2061. fi
  2062. # ============= zsh2.2/func/cx ==============
  2063. if test -f 'zsh2.2/func/cx' -a X"$1" != X"-c"; then
  2064.     echo 'x - skipping zsh2.2/func/cx (File already exists)'
  2065.     rm -f _shar_wnt_.tmp
  2066. else
  2067. > _shar_wnt_.tmp
  2068. echo 'x - extracting zsh2.2/func/cx (Text)'
  2069. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/cx' &&
  2070. X#! /bin/sh
  2071. X#
  2072. X# zsh shell function to make its arguments executable
  2073. X# also works as a sh script
  2074. X#
  2075. Xchmod +x $*
  2076. SHAR_EOF
  2077. chmod 0755 zsh2.2/func/cx ||
  2078. echo 'restore of zsh2.2/func/cx failed'
  2079. Wc_c="`wc -c < 'zsh2.2/func/cx'`"
  2080. test 109 -eq "$Wc_c" ||
  2081.     echo 'zsh2.2/func/cx: original size 109, current size' "$Wc_c"
  2082. rm -f _shar_wnt_.tmp
  2083. fi
  2084. # ============= zsh2.2/func/harden ==============
  2085. if test -f 'zsh2.2/func/harden' -a X"$1" != X"-c"; then
  2086.     echo 'x - skipping zsh2.2/func/harden (File already exists)'
  2087.     rm -f _shar_wnt_.tmp
  2088. else
  2089. > _shar_wnt_.tmp
  2090. echo 'x - extracting zsh2.2/func/harden (Text)'
  2091. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/harden' &&
  2092. X#! /bin/sh
  2093. X# harden a link (convert it to a singly linked file)
  2094. Xcp $1 $1.foo
  2095. Xrm $1
  2096. Xmv $1.foo $1
  2097. X
  2098. SHAR_EOF
  2099. chmod 0755 zsh2.2/func/harden ||
  2100. echo 'restore of zsh2.2/func/harden failed'
  2101. Wc_c="`wc -c < 'zsh2.2/func/harden'`"
  2102. test 97 -eq "$Wc_c" ||
  2103.     echo 'zsh2.2/func/harden: original size 97, current size' "$Wc_c"
  2104. rm -f _shar_wnt_.tmp
  2105. fi
  2106. # ============= zsh2.2/func/mere ==============
  2107. if test -f 'zsh2.2/func/mere' -a X"$1" != X"-c"; then
  2108.     echo 'x - skipping zsh2.2/func/mere (File already exists)'
  2109.     rm -f _shar_wnt_.tmp
  2110. else
  2111. > _shar_wnt_.tmp
  2112. echo 'x - extracting zsh2.2/func/mere (Text)'
  2113. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/mere' &&
  2114. X#! /bin/sh
  2115. X# read a man page in the current directory
  2116. Xnroff -man -Tman $1 | less -s
  2117. SHAR_EOF
  2118. chmod 0755 zsh2.2/func/mere ||
  2119. echo 'restore of zsh2.2/func/mere failed'
  2120. Wc_c="`wc -c < 'zsh2.2/func/mere'`"
  2121. test 84 -eq "$Wc_c" ||
  2122.     echo 'zsh2.2/func/mere: original size 84, current size' "$Wc_c"
  2123. rm -f _shar_wnt_.tmp
  2124. fi
  2125. # ============= zsh2.2/func/namedir ==============
  2126. if test -f 'zsh2.2/func/namedir' -a X"$1" != X"-c"; then
  2127.     echo 'x - skipping zsh2.2/func/namedir (File already exists)'
  2128.     rm -f _shar_wnt_.tmp
  2129. else
  2130. > _shar_wnt_.tmp
  2131. echo 'x - extracting zsh2.2/func/namedir (Text)'
  2132. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/namedir' &&
  2133. X# give a name to a directory
  2134. X
  2135. X$1=~+
  2136. X: ~$1
  2137. X
  2138. X# for example, if we say: namedir foo
  2139. X# where the current directory is /usr/princeton/common/src/news/nntp/inews
  2140. X# this will do:
  2141. X#
  2142. X# foo=/usr/princeton/common/src/news/nntp/inews
  2143. X# : ~foo
  2144. X#
  2145. X# The : ~foo just evaluates ~foo, which declares foo as a named directory.
  2146. X# The first time a parameter is used with tilde expansion, it is declared
  2147. X# as the name of a named dir.
  2148. SHAR_EOF
  2149. chmod 0755 zsh2.2/func/namedir ||
  2150. echo 'restore of zsh2.2/func/namedir failed'
  2151. Wc_c="`wc -c < 'zsh2.2/func/namedir'`"
  2152. test 412 -eq "$Wc_c" ||
  2153.     echo 'zsh2.2/func/namedir: original size 412, current size' "$Wc_c"
  2154. rm -f _shar_wnt_.tmp
  2155. fi
  2156. # ============= zsh2.2/func/proto ==============
  2157. if test -f 'zsh2.2/func/proto' -a X"$1" != X"-c"; then
  2158.     echo 'x - skipping zsh2.2/func/proto (File already exists)'
  2159.     rm -f _shar_wnt_.tmp
  2160. else
  2161. > _shar_wnt_.tmp
  2162. echo 'x - extracting zsh2.2/func/proto (Text)'
  2163. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/proto' &&
  2164. X#! /bin/sh
  2165. X# generate prototypes, if your style is the same as mine
  2166. Xfor i
  2167. Xdo
  2168. X    rm $i:r.pro 2>/dev/null
  2169. X    grep -v '[{};:#]' $i | grep '^[A-Za-z]' |
  2170. X        grep -v static | sed 's/$/;/' >! $i:r.pro
  2171. Xdone
  2172. SHAR_EOF
  2173. chmod 0755 zsh2.2/func/proto ||
  2174. echo 'restore of zsh2.2/func/proto failed'
  2175. Wc_c="`wc -c < 'zsh2.2/func/proto'`"
  2176. test 194 -eq "$Wc_c" ||
  2177.     echo 'zsh2.2/func/proto: original size 194, current size' "$Wc_c"
  2178. rm -f _shar_wnt_.tmp
  2179. fi
  2180. # ============= zsh2.2/func/randline ==============
  2181. if test -f 'zsh2.2/func/randline' -a X"$1" != X"-c"; then
  2182.     echo 'x - skipping zsh2.2/func/randline (File already exists)'
  2183.     rm -f _shar_wnt_.tmp
  2184. else
  2185. > _shar_wnt_.tmp
  2186. echo 'x - extracting zsh2.2/func/randline (Text)'
  2187. sed 's/^X//' << 'SHAR_EOF' > 'zsh2.2/func/randline' &&
  2188. X# get a random line from a file
  2189. SHAR_EOF
  2190. true || echo 'restore of zsh2.2/func/randline failed'
  2191. fi
  2192. echo 'End of zsh2.2 part 2'
  2193. echo 'File zsh2.2/func/randline is continued in part 3'
  2194. echo 3 > _shar_seq_.tmp
  2195. exit 0
  2196.  
  2197. exit 0 # Just in case...
  2198.